package com.homework;

/**
 * @Author 小闽
 * @Date 2024/10/14 10:59
 * @PackageName: com.homework
 * @ClassName: HomeWork5
 * @Description: 练习5
 * @Version 1.0
 */
public class HomeWork5 {
    public static void main(String[] args) {
        /**
         * 已知Animal类有属性name,
         * 可以通过有参构造为属性赋值
         */
        String s1 = "苏宁易购";
        Animal animal = new Animal(s1);
        Animal animal1 = new Animal(s1);
        System.out.println(animal == animal1); // false
        System.out.println(animal.equals(animal1)); // false
        System.out.println(animal.name == animal1.name); // true
        String s4 = new String("苏宁易购");
        String s5 = "苏宁易购";
        System.out.println(s1 == s4); // false
        System.out.println(s4 == s5); // false
        String t1 = "hello" + s1;
        String t2 = "hello苏宁易购";
        System.out.println(t1.intern() == t2); // true
    }
}
class Animal{
    String name;
    public Animal(String name){
        this.name = name;
    }
}
